package com.smh.a01IOStreamDemo1;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class IOStreamDemo9 {
    public static void main(String[] args) {
//        try catch finally
//        FileInputStream fis = null;
//        FileOutputStream fos = null;
        //Jdk7的自动释放资源,当然只有实现了AutoCloseable接口的类,才能这么写
        try (FileInputStream fis = new FileInputStream("day26-code\\file\\a.txt"); FileOutputStream fos = new FileOutputStream("day26-code\\file\\b.txt")) {
            byte[] bytes = new byte[1024 * 1024];
            int len;

            while ((len = fis.read(bytes)) > 0) {
                fos.write(bytes, 0, len);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }
}
